package com.crowd.mapper;

import com.crowd.entity.Role;
import com.crowd.entity.RoleExample;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface RoleMapper {
    int countByExample(RoleExample example);

    int deleteByExample(RoleExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Role record);

    int insertSelective(Role record);

    List<Role> selectByExample(RoleExample example);

    Role selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Role record, @Param("example") RoleExample example);

    int updateByExample(@Param("record") Role record, @Param("example") RoleExample example);

    int updateByPrimaryKeySelective(Role record);

    int updateByPrimaryKey(Role record);

    //通过关键词查询角色
    List<Role> selectRoleByKeyword(String keyword);

    // 找到已分配给此用户的角色list
    List<Role> selectAssignedRoleList(Integer adminId);

    // 找到未分配给此用户的角色list
    List<Role> selectUnAssignedRoleList(Integer adminId);

    // 给用户分配新的角色权限
    // 1.删除旧角色权限
    void deleteOldAdminRoleRelationship(Integer adminId);
    // 2.添加新角色权限
    void insertNewAdminRoleRelationship(@Param("adminId") Integer adminId,@Param("assignedRoleList") List<Integer> assignedRoleList);
}